<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>01-jQuery对象进行方法扩展</title>
    <script src="../../js/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
    	/*表示定义jquery的对象的插件--》注意格式*/
    	$.fn.extend({
    		check:function(){
    			//this:调用该方法的jq对象
    			this.prop("checked",true);
    		},
    		uncheck:function(){
    				this.prop("checked",false);
    		}
    		
    	});
		$(function(){
			$("#btn-check").click(function(){
				$(":checkbox").check();
			});
			
			$("#btn-uncheck").click(function(){
				$(":checkbox").uncheck();
			});
			
		});
		/*function checkFn(){
				$(":checkbox").attr("checked",true);
			};
		function uncheckFn(){
			$(":checkbox").attr("checked",false);
		}*/
    </script>
</head>
<body>
<input id="btn-check" type="button" value="点击选中复选框" onclick="checkFn()">
<input id="btn-uncheck" type="button" value="点击取消复选框选中" onclick="uncheckFn()">
<br/>
<input type="checkbox" value="football">足球
<input type="checkbox" value="basketball">篮球
<input type="checkbox" value="volleyball">排球

</body>
</html>

